import 'package:flutter_fronter_service/generated/json/base/json_convert_content.dart';
import 'package:flutter_fronter_service/model/address_entity.dart';

AddressEntity $AddressEntityFromJson(Map<String, dynamic> json) {
  final AddressEntity addressEntity = AddressEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    addressEntity.id = id;
  }
  final String? contactName = jsonConvert.convert<String>(json['contactName']);
  if (contactName != null) {
    addressEntity.contactName = contactName;
  }
  final int? contactSex = jsonConvert.convert<int>(json['contactSex']);
  if (contactSex != null) {
    addressEntity.contactSex = contactSex;
  }
  final String? contactTel = jsonConvert.convert<String>(json['contactTel']);
  if (contactTel != null) {
    addressEntity.contactTel = contactTel;
  }
  final String? province = jsonConvert.convert<String>(json['province']);
  if (province != null) {
    addressEntity.province = province;
  }
  final String? city = jsonConvert.convert<String>(json['city']);
  if (city != null) {
    addressEntity.city = city;
  }
  final String? district = jsonConvert.convert<String>(json['district']);
  if (district != null) {
    addressEntity.district = district;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    addressEntity.address = address;
  }
  final bool? defaultAddress = jsonConvert.convert<bool>(
      json['defaultAddress']);
  if (defaultAddress != null) {
    addressEntity.defaultAddress = defaultAddress;
  }
  return addressEntity;
}

Map<String, dynamic> $AddressEntityToJson(AddressEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['contactName'] = entity.contactName;
  data['contactSex'] = entity.contactSex;
  data['contactTel'] = entity.contactTel;
  data['province'] = entity.province;
  data['city'] = entity.city;
  data['district'] = entity.district;
  data['address'] = entity.address;
  data['defaultAddress'] = entity.defaultAddress;
  return data;
}

extension AddressEntityExtension on AddressEntity {
  AddressEntity copyWith({
    int? id,
    String? contactName,
    int? contactSex,
    String? contactTel,
    String? province,
    String? city,
    String? district,
    String? address,
    bool? defaultAddress,
  }) {
    return AddressEntity()
      ..id = id ?? this.id
      ..contactName = contactName ?? this.contactName
      ..contactSex = contactSex ?? this.contactSex
      ..contactTel = contactTel ?? this.contactTel
      ..province = province ?? this.province
      ..city = city ?? this.city
      ..district = district ?? this.district
      ..address = address ?? this.address
      ..defaultAddress = defaultAddress ?? this.defaultAddress;
  }
}